Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc fixes #724

Merged
merged 1 commit into from
Jun 13, 2024
Merged

misc fixes #724

merged 1 commit into from
Jun 13, 2024

Conversation

zarSou9
Copy link
Contributor

@zarSou9 zarSou9 commented Jun 13, 2024

No description provided.

@@ -40,6 +45,7 @@ const addPopup = (e: HTMLElement, id: string, contents: string, mobile?: boolean
const toggle = () => popup.classList.toggle('shown')
popup.addEventListener('click', togglePopup(toggle, e))
e.addEventListener('click', togglePopup(toggle, e))
popup.children[0].addEventListener('click', (e) => e.stopPropagation())
}

return popup
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mruwnik, ok so there is a problem with multiple popups being added to a reference item for definitions. I think specifically, because the id is generated randomly, there can still exist two popups associated with the same reference whenever the function which creates the random ids is run more than once. And because react tends to just run things randomly...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried fixing this myself but I couldn't figure it out

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm. You're right :/ One way round this would be to pass in the id, rather than use a random one. So normal articles would just leave it empty, and chatbot ones would pass in their index in the history.

Otherwise the id would have to be generated based on the contents somehow, which would work for chat responses (as most of the time they will be unique), but not for articles in the chatbot (unless they have some magic token added secretly, which is also ugly). In this case the randomId would just be a hash of the html argument or something

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried again but I think this problem has far deeper and darker roots...
image
They are replicating inside each-other. Its like trying to fight hydra

@zarSou9 zarSou9 requested a review from mruwnik June 13, 2024 03:09
@@ -40,6 +45,7 @@ const addPopup = (e: HTMLElement, id: string, contents: string, mobile?: boolean
const toggle = () => popup.classList.toggle('shown')
popup.addEventListener('click', togglePopup(toggle, e))
e.addEventListener('click', togglePopup(toggle, e))
popup.children[0].addEventListener('click', (e) => e.stopPropagation())
}

return popup
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm. You're right :/ One way round this would be to pass in the id, rather than use a random one. So normal articles would just leave it empty, and chatbot ones would pass in their index in the history.

Otherwise the id would have to be generated based on the contents somehow, which would work for chat responses (as most of the time they will be unique), but not for articles in the chatbot (unless they have some magic token added secretly, which is also ugly). In this case the randomId would just be a hash of the html argument or something

@zarSou9 zarSou9 merged commit 95ca082 into stampy-redesign Jun 13, 2024
1 check passed
@zarSou9 zarSou9 deleted the mobile-footnotes branch June 13, 2024 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants